class Solution {
public:
    int canBeTypedWords(string text, string brokenLetters) {
        bool hash[26] = { 0 };
        for (auto ch : brokenLetters)
            hash[ch - 'a'] = 1;

        int count = 0;
        bool is_b = false;
        for (auto ch : text) {
            if (ch == ' ' && is_b == false) count++;
            else if (ch == ' ' && is_b == true) is_b = false;
            else if (hash[ch - 'a']) is_b = true;
        }
        if (is_b == false) count++;

        return count;
    }
};